﻿<%@ Page Title="" Language="C#" MasterPageFile="~/forumMaster.Master" AutoEventWireup="true" CodeBehind="UserArea.aspx.cs" Inherits="forum.UserArea" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script type="text/javascript">
    $(document).ready(function () {
        $("#lnkbtnComplaint").click(function () {
            $("#complaintPopUp").dialog("open");
            var dialog = $(".ui-dialog");
            var left = ($(window).width() / 2) - (dialog.width() / 2);
            dialog.css({ top: 150, left: left });
            return false;
        });


        $("#ddlSubForumAComplaint").change(function () {
            parameters = "{'subForumName':'" + $("#ddlSubForumAComplaint option:selected").text() + "'}";
            $.ajax({
                type: "POST",
                url: "../Ajax/forumAjax.asmx/getModeratorsBySubForum",
                contentType: "application/json; charset=utf-8",
                data: parameters,
                dataType: "json",
                success: function (result) {
                    $("#ddlModerators").html(result.d);
                },
                error: function () {
                    return false;
                }
            });
        });

        $("#complaintPopUp").dialog({
            autoOpen: false,
            title: "Complain moderator",
            modal: true,
            buttons: {
                "ok": function () {

                    var parameters;
                    var subForumId = $("#ddlSubForumAComplaint").val();
                    var moderatorId = $("#ddlModerators").val();
                    if (moderatorId != "0") {
                        parameters = "{'subForumId':'" + subForumId + "','moderatorId': '" + moderatorId + "'}";
                        $.ajax({
                            type: "POST",
                            url: "../Ajax/forumAjax.asmx/complaineModerator",
                            contentType: "application/json; charset=utf-8",
                            data: parameters,
                            dataType: "json",
                            success: function (result) {
                                if (result.d != "bad") {
                                    alert("Complain accepted");
                                    location.reload();
                                    return false;
                                }
                                else {
                                    alert("you already complained on this moderator in this forum");
                                    return false;
                                }
                            },
                            error: function () {
                                return false;
                            }
                        });
                    }
                    else {
                        alert("Please Choose Moderator");
                        return false;
                    }

                    $(this).dialog("close");
                    return false;
                },
                "cancel": function () {
                    $(this).dialog("close");
                }
            }
        });

    });


</script>
</asp:Content>


<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  
<div "userMenu>
    <ul>
        <li><asp:LinkButton ID="lnkbtnComplaint" ClientIDMode="Static" runat="server">Complaint Moderator</asp:LinkButton></li>
    </ul>
</div>


<div id="complaintPopUp">
        <asp:Label class="popUpTitle" ID="lblSubForumAddComplaintPopUp" ClientIDMode="Static" runat="server" Text="Choose forum"></asp:Label>
        <asp:DropDownList ID="ddlSubForumAComplaint" ClientIDMode="Static" runat="server"></asp:DropDownList>
        <asp:Label ID="lblModeratorComplaintPopUp" class="popUpTitle" ClientIDMode="Static" runat="server" Text="Choose Moderator"></asp:Label>
        <asp:DropDownList ID="ddlModerators" ClientIDMode="Static" runat="server"></asp:DropDownList>
</div>
</asp:Content>
